{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "outputs": [
    {
     "data": {
      "text/plain": "                 日期0       日期1        日期3        日期4                  日期5  \\\n日期2                                                                         \n2020-01-20  20200120  20200120  1/20/2020  2020/1/20  2020-01-20 00:10:10   \n2020-01-21  20200121  20200121  1/21/2020  2020/1/21  2020-01-21 00:10:11   \n\n                  日期6  \n日期2                    \n2020-01-20 2020-01-20  \n2020-01-21 2020-01-21  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>日期0</th>\n      <th>日期1</th>\n      <th>日期3</th>\n      <th>日期4</th>\n      <th>日期5</th>\n      <th>日期6</th>\n    </tr>\n    <tr>\n      <th>日期2</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2020-01-20</th>\n      <td>20200120</td>\n      <td>20200120</td>\n      <td>1/20/2020</td>\n      <td>2020/1/20</td>\n      <td>2020-01-20 00:10:10</td>\n      <td>2020-01-20</td>\n    </tr>\n    <tr>\n      <th>2020-01-21</th>\n      <td>20200121</td>\n      <td>20200121</td>\n      <td>1/21/2020</td>\n      <td>2020/1/21</td>\n      <td>2020-01-21 00:10:11</td>\n      <td>2020-01-21</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 23
    }
   ],
   "source": [
    "df = pd.read_excel(\n",
    "    'parse_dates.xlsx',\n",
    "    index_col=2\n",
    ")\n",
    "df"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "outputs": [
    {
     "data": {
      "text/plain": "Index(['2020-01-20', '2020-01-21'], dtype='object', name='日期2')"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 24
    }
   ],
   "source": [
    "df.index"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "outputs": [
    {
     "data": {
      "text/plain": "DatetimeIndex(['2020-01-20', '2020-01-21'], dtype='datetime64[ns]', name='日期2', freq=None)"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 25
    }
   ],
   "source": [
    "df = pd.read_excel(\n",
    "    'parse_dates.xlsx',\n",
    "    index_col=2,\n",
    "    parse_dates=True\n",
    ")\n",
    "df.index"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "outputs": [
    {
     "data": {
      "text/plain": "日期0             int64\n日期1             int64\n日期2            object\n日期3            object\n日期4            object\n日期5            object\n日期6    datetime64[ns]\ndtype: object"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 26
    }
   ],
   "source": [
    "df = pd.read_excel(\n",
    "    'parse_dates.xlsx'\n",
    ")\n",
    "df.dtypes"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "outputs": [
    {
     "data": {
      "text/plain": "日期0    datetime64[ns]\n日期1    datetime64[ns]\n日期2    datetime64[ns]\n日期3    datetime64[ns]\n日期4    datetime64[ns]\n日期5    datetime64[ns]\n日期6    datetime64[ns]\ndtype: object"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 27
    }
   ],
   "source": [
    "df = pd.read_excel(\n",
    "    'parse_dates.xlsx',\n",
    "    parse_dates=[0, 1, 2, 3, 4, 5, 6]\n",
    ")\n",
    "df.dtypes"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "outputs": [
    {
     "data": {
      "text/plain": "      年  月   日   销量\n0  2020  1  20  100\n1  2020  1  21  200",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>年</th>\n      <th>月</th>\n      <th>日</th>\n      <th>销量</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2020</td>\n      <td>1</td>\n      <td>20</td>\n      <td>100</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2020</td>\n      <td>1</td>\n      <td>21</td>\n      <td>200</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 28
    }
   ],
   "source": [
    "df = pd.read_excel(\n",
    "    'parse_dates.xlsx',\n",
    "    sheet_name=1,\n",
    ")\n",
    "df"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "outputs": [
    {
     "data": {
      "text/plain": "       年_月_日   销量\n0 2020-01-20  100\n1 2020-01-21  200",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>年_月_日</th>\n      <th>销量</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2020-01-20</td>\n      <td>100</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2020-01-21</td>\n      <td>200</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 29
    }
   ],
   "source": [
    "df = pd.read_excel(\n",
    "    'parse_dates.xlsx',\n",
    "    sheet_name=1,\n",
    "    # parse_dates=[[0, 1, 2]],\n",
    "    parse_dates=[['年', '月', '日']],\n",
    ")\n",
    "df"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "outputs": [
    {
     "data": {
      "text/plain": "年_月_日    datetime64[ns]\n销量                int64\ndtype: object"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 30
    }
   ],
   "source": [
    "df.dtypes\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "outputs": [
    {
     "data": {
      "text/plain": "          日期   销量\n0 2020-01-20  100\n1 2020-01-21  200",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>日期</th>\n      <th>销量</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>2020-01-20</td>\n      <td>100</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2020-01-21</td>\n      <td>200</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 31
    }
   ],
   "source": [
    "df = pd.read_excel(\n",
    "    'parse_dates.xlsx',\n",
    "    sheet_name=1,\n",
    "    parse_dates={'日期': ['年', '月', '日']},\n",
    ")\n",
    "df"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "outputs": [
    {
     "data": {
      "text/plain": "日期    datetime64[ns]\n销量             int64\ndtype: object"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 32
    }
   ],
   "source": [
    "df.dtypes"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}